package com.wenlong.crud.controller;

import com.wenlong.crud.pojo.Department;
import com.wenlong.crud.pojo.Msg;
import com.wenlong.crud.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author 苏文龙
 * @version 1.0
 * 处理与部门相关的Controller
 */
@Controller
public class DepartMentController {
    @Autowired
    private DepartmentService departmentService;

    /**
     * 返回所有部门对象
     * @return
     */
    @RequestMapping("/depts")
    @ResponseBody
    public Msg getDepts(){
        List<Department> departments = departmentService.getDepts();
        return Msg.Success().add("depts", departments);
    }
}
